<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="./promise2-then.js"></script>
    <script>
        let p = new Promise((resolve, reject) => {
            // resolve(2)
            // reject(3);
            setTimeout(() => {
                // resolve(111);
                reject('222')
            }, 3000)
        });

        p.then (value => {
            console.log("onResolved1----" + value);
            // 1/回调函数返还的结果为promise
            // return new Promise((resolve, reject) => {
            //     // resolve(111);
            //     // reject(222)
            // })
            //2.返回非promise的值
            // return 333;
            // 3.抛出错误
            // throw 555

            // setTimeout(() => {
            //     return new Promise((resolve, reject) => {
            //         resolve(111);
            //     // reject(222)
            //     })
            // }, 1000);//不被允许
            // setTimeout(() => {
            //     return 333;
            // }, 1000);
           
        }, reason => {
            console.log("onRejected1----" + reason);
            throw 444;
        }).catch ((reason) => {
            console.log('错误的----' + reason);
        }) 
        .then (value => {
            console.log("onResolved2----" + value);
        }, reason => {
            console.log("onRejected2----" + reason);
        })




        // p.then (value => {
        //     console.log("onResolved2----" + value);
        // }, reason => {
        //     console.log("onRejected2----" + reason);
        // })
        console.log(p);
    </script>
</body>
</html>